/*********************************************************************************
 *Author:         OnClick
 *Version:        1.0
 *UnityVersion:   2018.3.1f1
 *Date:           2019-01-28
 *Description:    IFramework
 *History:        2018.11--
*********************************************************************************/
namespace IFramework
{
	public class AStarNode3X:IAStarNode
	{
        private AStarNodeType nodeType;
        private IAStarNode parentNode;
        private float g;
        private float h;
        public AStarNodeType NodeType { get { return nodeType; } }
        public IAStarNode ParentNode { get { return parentNode; } }
        public float G { get { return g; } }
        public float H { get { return h; } }
        public float F { get { return g + h; ; } }
        private int mapPosX;
        private int mapPosY;
        private int mapPosZ;
        public int MapPosZ { get { return mapPosZ; } }
        public int MapPosY { get { return mapPosY; } }
        public int MapPosX { get { return mapPosX; } }
        public AStarNode3X(int mapPosX, int mapPosY,int mapPosZ, AStarNodeType nodeType)
        {
            this.mapPosX = mapPosX;
            this.mapPosY = mapPosY;
            this.mapPosZ = mapPosZ;
            g = h = float.MaxValue / 2;
            this.nodeType = nodeType;
        }

        public void SetDefaultParent(IAStarNode node)
        {
            this.parentNode = node;
        }

        public float TryUpdateFCost(float g, float h, IAStarNode trySetNode)
        {
            if (g + h < F)
            {
                this.g = g;
                this.h = h;
                this.parentNode = trySetNode;
            }
            return F;
        }

        public void Reset()
        {
            g = h = float.MaxValue / 2;
            parentNode = null;
        }
    }
}
